package Method;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class Exercise {
    public static void main(String[] args) throws InterruptedException {
        T3 t3 = new T3();
        Thread thread = new Thread(t3);
        for (int i = 1;i<=10;i++){
            System.out.println("hi" + i);
            Thread.sleep(1000);
            if(i == 5){
                thread.start();
                thread.join();
                System.out.println("子线程结束...");
            }

        }
        System.out.println("主线程结束...");
    }
}
class T3 implements Runnable{
private int count = 0;
    @Override
    public void run() {

    while (count < 10){
        System.out.println("hello" + (++count));

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    }
}
